package com.aptemo.webetek.server.datastore;

import java.util.Date;
import java.util.List;

import com.aptemo.webetek.client.enums.EnumBetStatus;
import com.aptemo.webetek.client.enums.EnumBetType;
import com.aptemo.webetek.client.enums.EnumEventStatus;
import com.aptemo.webetek.client.enums.EnumEventType;
import com.aptemo.webetek.client.enums.EnumPaymentOrdering;
import com.aptemo.webetek.client.enums.EnumPaymentType;
import com.aptemo.webetek.client.enums.EnumTeamOrdering;
import com.aptemo.webetek.client.enums.EnumUserOrdering;
import com.aptemo.webetek.client.enums.EnumUserRole;
import com.aptemo.webetek.client.enums.EnumUserStatus;
import com.aptemo.webetek.client.exceptions.BackendException;
import com.aptemo.webetek.shared.BetBean;
import com.aptemo.webetek.shared.EventBean;
import com.aptemo.webetek.shared.LabelBean;
import com.aptemo.webetek.shared.PagingResult;
import com.aptemo.webetek.shared.PaymentBean;
import com.aptemo.webetek.shared.PickBean;
import com.aptemo.webetek.shared.TeamBean;
import com.aptemo.webetek.shared.UserBean;

public interface DataStoreAPI
{
	// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Get API
	TeamBean getTeam(String teamId) throws BackendException;

	EventBean getEvent(String gameId) throws BackendException;

	UserBean getPlayer(String userid) throws BackendException;

	PaymentBean getPayment(String userid) throws BackendException;

	BetBean getBet(String userid) throws BackendException;

	LabelBean getLabel(String labelid) throws BackendException;

	PickBean getPick(String pickId) throws BackendException;

	// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// delete API
	boolean deleteTeam(String id);

	boolean deleteEvent(String id) throws BackendException;

	boolean deletePlayer(String id) throws BackendException;

	boolean deleteLabel(String id) throws BackendException;

	boolean deletePayment(String id) throws BackendException;

	// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Modify API
	TeamBean modifyTeam(TeamBean bean) throws BackendException;

	EventBean modifyEvent(EventBean bean) throws BackendException;

	UserBean modifyPlayer(UserBean bean) throws BackendException;

	LabelBean modifyLabel(LabelBean bean) throws BackendException;

	PickBean modifyPick(PickBean bean) throws BackendException;

	// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Create API
	TeamBean createTeam(String name, String description, String teamRules, String ownerId, boolean publicity, boolean notifications, Double minStake,
			Double maxStake) throws BackendException;;

	EventBean createEvent(String teamid, String title, String description, Date date, List<PickBean> picks, EnumEventType type, String labelId)
			throws BackendException;

	UserBean createPlayer(String teamId, String email, EnumUserStatus invited, EnumUserRole role, double initialBalance) throws BackendException;

	PaymentBean createPayment(String userId, String teamId, double amount, EnumPaymentType type) throws BackendException;

	BetBean createBet(String userId, String teamId, double amount, List<String> pickKeys, EnumBetType type) throws BackendException;

	LabelBean createLabel(String teamId, String title) throws BackendException;

	// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Queries
	List<TeamBean> getTeams(String nameFilter, boolean publicity, EnumTeamOrdering order) throws BackendException;

	List<EventBean> getEvents(String teamId, String labelId, Date treshold, EnumEventStatus status) throws BackendException;

	List<UserBean> getPlayers(String teamId, EnumUserStatus status, EnumUserOrdering order) throws BackendException;

	List<BetBean> getBets(String userId, EnumBetStatus status) throws BackendException;

	List<PaymentBean> getPayments(String userId, EnumPaymentType type, EnumPaymentOrdering order) throws BackendException;

	List<LabelBean> getLabels(String teamId) throws BackendException;

	List<String> getPicksForEvent(String userId, String betId) throws BackendException;

	// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Queries with paging----
	PagingResult<TeamBean> getTeams(String nameFilter, boolean publicity, EnumTeamOrdering order, String cursor, int pageSize) throws BackendException;

	PagingResult<EventBean> getEvents(String teamId, String labelId, Date treshold, EnumEventStatus status, String cursor, int pageSize)
			throws BackendException;

	PagingResult<UserBean> getPlayers(String teamId, EnumUserStatus status, EnumUserOrdering order, String cursor, int pageSize) throws BackendException;

	PagingResult<BetBean> getBets(String teamId, String userId, EnumBetStatus status, String cursor, int pageSize) throws BackendException;

	PagingResult<PaymentBean> getPayments(String userId, EnumPaymentType type, EnumPaymentOrdering order, String cursor, int pageSize) throws BackendException;

	// //

	EventBean assignResultPick(String pickkey, String comment);

	List<UserBean> completeStakes(String eventkey);

}
